package org.example.controller;

import org.example.dto.ShoppingUser;
import org.example.rvo.ResultVO;
import org.example.service.ShoppingUserService;
import org.example.util.TUserThreadLocal;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/api/user",produces = "application/json;charset=utf-8")
public class ShoppingUserController {

    @Resource
    private ShoppingUserService shoppingUserService;

    @PostMapping("/login")
    public ResultVO login(@RequestBody ShoppingUser shoppingUser) throws Exception {
        return shoppingUserService.login(shoppingUser.getUserName(),shoppingUser.getUserPass());
    }

    @GetMapping("/queryMySelf")
    public ResultVO queryMySelf() throws Exception {
        ShoppingUser user = TUserThreadLocal.get();
        return shoppingUserService.queryMySelf(user.getId());

    }
}
